#ifndef __LOGGING_SDCARD__
#define __LOGGING_SDCARD__
/*
	mini-SD Card Logging

	Sequence:
		Initialise device
			-Find blank sector
			-Find the last Log Numbers
			-Reset to zero Sequence No
			-Return T/F if logging Initialised

		Write
			-Check size of device is OK
			-Create the DTS header, Log Number etc
*/

typedef struct _typLoggCommHdr {
	uint8_t	nId;
} _typLoggCommHdr;

typedef struct _typLoggCommReport {
	uint8_t	 nId;
	uint32_t dts;
	uint32_t nCnt;
	uint32_t nCrntSector;
	uint32_t nCrntSeqNo;
} _typLoggCommReport;

typedef struct _typLogSeek {
	uint32_t	nLogNo;
	uint32_t	nSeqNo;
} _typLogSeek;

typedef enum eLogRtn {
	eLogFail,
	eLogOk,
	eLogSdRdFail,
	eLogSdWrFail,
	eLogNoSpace,
	eLogNoCard
} eLogRtn;

// Initialise the Logging, return true is logging is oK
uint8_t log_init(uint32_t dts);

// Write the logging data
uint8_t	log_write(uint8_t* pchBuffer, uint16_t nSize);
uint8_t log_write_entry(uint8_t* pchBuffer, uint16_t nSize,uint32_t nTicks);

// Seek to the log number
uint8_t	log_read_seek(uint32_t nLogNo, uint32_t nSeqNo);

// Read the next entry to the previously seeked item
uint8_t log_read_next(void);
uint8_t log_read_compressed_next(void);

// Report all SD card usage to comm
uint8_t log_read_report_usage(void);
uint8_t	log_read_report_info(uint32_t nLogNo);

#endif

